import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '订单号',
    align:"center",
    dataIndex: 'orderNum'
   },
   {
    title: '客户编码',
    align:"center",
    dataIndex: 'cusCode'
   },
   {
    title: '客户名称',
    align:"center",
    dataIndex: 'cusName'
   },
   {
    title: '预计到货时间',
    align:"center",
    dataIndex: 'arrivalDate'
   },
   {
    title: '司机',
    align:"center",
    dataIndex: 'carDriver'
   },
  
   {
    title: '订单类型名称',
    align:"center",
    dataIndex: 'orderTypeName'
   },
   {
    title: '单据状态',
    align:"center",
    dataIndex: 'orderStatus'
   },
   
   {
    title: '供应商编码',
    align:"center",
    dataIndex: 'supCode'
   },
   {
    title: '供应商名称',
    align:"center",
    dataIndex: 'supName'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "客户编码",
      field: 'cusCode',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "订单类型编码",
      field: 'orderTypeCode',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "订单号",
      field: 'orderNum',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "客户名称",
      field: 'cusName',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '客户编码',
    field: 'cusCode',
    required:true,
    component: 'JPopup',
    colProps: {
      span: 12,
    },        
    componentProps: ({ formActionType }) => {
      let { setFieldsValue } = formActionType
      return {
          setFieldsValue,
          placeholder: '请选择',
          code: 'wms_cus',
          fieldConfig: [{ source: 'cus_code', target: 'cusCode' }, { source: 'cus_name', target: 'cusName' }],
          multi: true,
      }
    },         
  },
  {
    label: '客户名称',
    field: 'cusName',
    component: 'Input',
    colProps: {
      span: 12,
    }, 
    componentProps: {
      disabled: true,
    },
  },
  {
    label: '预计到货时间',
    field: 'arrivalDate',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '司机',
    field: 'carDriver',
    component: 'Input',
  },
  {
    label: '订单类型编码',
    field: 'orderTypeCode',
    component: 'JPopup',
    required:true,
    colProps: {
      span: 12,
    },        
    componentProps: ({ formActionType }) => {
      let { setFieldsValue } = formActionType
      return {
          setFieldsValue,
          placeholder: '请选择',
          code: 'wms_order_type',
          fieldConfig: [{ source: 'order_type_code', target: 'orderTypeCode' }, { source: 'order_type_name', target: 'orderTypeName' }],
          multi: true,
      }
    },   
  },
  {
    label: '订单类型名称',
    field: 'orderTypeName',
    component: 'Input',
    componentProps: {
      disabled: true,
    },
  },
  {
    label: '供应商编码',
    field: 'supCode',
    component: 'JPopup',
    required:true,
    colProps: {
      span: 12,
    },        
    componentProps: ({ formActionType }) => {
      let { setFieldsValue } = formActionType
      return {
          setFieldsValue,
          placeholder: '请选择',
          code: 'wms_supply',
          fieldConfig: [{ source: 'suply_code', target: 'supCode' }, { source: 'suply_name', target: 'supName' }],
          multi: true,
      }
    },   
  },
  {
    label: '供应商名称',
    field: 'supName',
    component: 'Input',
    componentProps: {
      disabled: true,
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表列表数据
export const wmsOrderLineColumns: BasicColumn[] = [
   {
    title: '订单号',
    align:"center",
    dataIndex: 'orderNum'
   },
   {
    title: '物料编码',
    align:"center",
    dataIndex: 'goodsCode'
   },
   {
    title: '物料名称',
    align:"center",
    dataIndex: 'goodsName'
   },
   {
    title: '订单数量',
    align:"center",
    dataIndex: 'goodsCount'
   },
   {
    title: '未验收数量',
    align:"center",
    dataIndex: 'goodsSyCount'
   },
   {
    title: '已验收数量',
    align:"center",
    dataIndex: 'goodsDjCount'
   },
   {
    title: '生产日期',
    align:"center",
    dataIndex: 'goodsProDate'
   },
   {
    title: '批次',
    align:"center",
    dataIndex: 'goodsBatch'
   },
   {
    title: '规格',
    align:"center",
    dataIndex: 'goodsSpec'
   },
   {
    title: '单位名称',
    align:"center",
    dataIndex: 'goodsUnitName'
   },
   
   {
    title: '明细状态',
    align:"center",
    dataIndex: 'lineStatus'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
];
//子表表格配置
export const wmsOrderLineJVxeColumns: JVxeColumn[] = [
    {
      title: '物料编码',
      key: 'goodsCode',
      type: JVxeTypes.popup,
      width: "200px",
      popupCode: 'wms_goods',
      fieldConfig: [
        { source: 'goods_code', target: 'goodsCode' },
        { source: 'goods_name', target: 'goodsName' },
        { source: 'unit_code', target: 'goodsUnitCode' },
        { source: 'unit_name', target: 'goodsUnitName' },
        { source: 'goods_spec', target: 'goodsSpec' },
        { source: 'goods_pro_date', target: 'goodsProDate' },
      ],
    },
    {
      title: '物料名称',
      key: 'goodsName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled:true,
    },
    {
      title: '批次',
      key: 'goodsBatch',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单据数量',
      key: 'goodsCount',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '未验收数量',
      key: 'goodsSyCount',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled:true,
    },
    {
      title: '已验收数量',
      key: 'goodsDjCount',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled:true,
    },
    {
      title: '生产日期',
      key: 'goodsProDate',
      type: JVxeTypes.datetime,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled:true,
    },
    {
      title: '单位编码',
      key: 'goodsUnitCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled:true,
    },
    {
      title: '单位名称',
      key: 'goodsUnitName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled:true,
    },
    {
      title: '规格',
      key: 'goodsSpec',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled:true,
    },
    {
      title: '备注',
      key: 'remark',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}